﻿// -------------------------------------------------------------------------------------------------------------------------------
// <copyright file="EmptyCollectionException.cs" company="Exul">
//     Copyright (c) Exul. All rights reserved.
// </copyright>
// <author>
//     Exul
// </author>
// -------------------------------------------------------------------------------------------------------------------------------

namespace ExulLibrary.Exceptions
{
    #region Usings

    using System;
    using System.Globalization;
    using System.Runtime.Serialization;

    using ExulLibrary.Properties;

    #endregion

    /// <summary>
    ///     Describes an error when empty collection is passed as value of parameter that doesn't support it.
    /// </summary>
    [Serializable]
    public sealed class EmptyCollectionException : ArgumentException
    {
        #region Constructors and Destructors

        #region public

        /// <summary>
        ///     Initializes a new instance of the <see cref="EmptyCollectionException"/> class.
        /// </summary>
        /// <param name="paramName">
        ///     The parameter name.
        /// </param>
        public EmptyCollectionException(string paramName)
            :
                base(Resources.ArgumentIsEmptyCollection, paramName, null)
        {
        }

        /// <summary>
        ///     Initializes a new instance of the <see cref="EmptyCollectionException"/> class.
        /// </summary>
        /// <param name="paramName">
        ///     The parameter name.
        /// </param>
        /// <param name="message">
        ///     The message that describes the error.
        /// </param>
        public EmptyCollectionException(string paramName, string message)
            : base(message, paramName, null)
        {
        }

        #endregion

        #region private

        /// <summary>
        ///     Initializes a new instance of the <see cref="EmptyCollectionException"/> class.
        /// </summary>
        /// <param name="info">
        ///     The object that holds the serialized object data.
        /// </param>
        /// <param name="context">
        ///     The contextual information about the source or destination.
        /// </param>
        private EmptyCollectionException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        #endregion

        #endregion

        #region Overridden Properties

        #region public

        /// <summary>
        ///     Gets the error message and the parameter name, or only the error message if no parameter name is set.
        /// </summary>
        /// <value>
        ///     A text string describing the details of the exception.
        /// </value>
        public override string Message
        {
            get
            {
                return string.Format(CultureInfo.CurrentCulture, base.Message, this.ParamName);
            }
        }

        #endregion

        #endregion
    }
}